package mchecca.model;

/**
 * Class for an edge in a DLE.
 * <p>
 * An edge has the following properties
 * <ul>
 * 	<li>Left choice</li>
 * 	<li>Right choice</li>
 * 	<li>Height (in pixels)</li>
 * </ul>
 * @author Michael Checca
 */
public class Edge {
	/** Number of left line */
	int left;
	/** Number of right line */
	int right;
	/** Height in pixels */
	int height;

	/**
	 * Create a new edge.
	 * <p>
	 * The {@link Edge} connects two lines neighboring each other
	 * @param left Number of left line
	 * @param right Number of right line
	 * @param height Height in pixels
	 */
	public Edge(int left, int right, int height) {
		this.left = left;
		this.right = right;
		this.height = height;
	}

	/**
	 * Gets the left line number
	 * @return Number of the left line
	 */
	public int getLeft() {
		return left;
	}

	/**
	 * Gets the right line number
	 * @return Number of the right line
	 */
	public int getRight() {
		return right;
	}

	/**
	 * Gets the height in pixels of the edge
	 * @return Height in pixels from the top
	 */
	public int getHeight() {
		return height;
	}

	/**
	 * Determines if two {@link Edge}s are equal
	 * <p>
	 * Two {@link Edge}s are equal if the have the same
	 * <ul>
	 * 	<li>Left choice</li>
	 * 	<li>Right choice</li>
	 * 	<li>Height in pixels</li>
	 * </ul>
	 * @param obj Other object to compare to this {@link Edge}
	 * @return True if obj is the same is this object, false otherwise
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Edge) {
			Edge other = (Edge) obj;
			return left == other.left && right == other.right && height == other.height;
		}
		return false;
	}

	/**
	 * Formats this {@link Edge} nicely into a string.
	 * @return String representation of this {@link Edge}
	 */
	@Override
	public String toString() {
		return String.format("Edge [l:%d, r:%d, h:%d]", left, right, height);
	}
}
